<template>
	<view>
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">随手拍</block>
		</cu-custom>
		<view class="img">
			<image src="../../../static/BasicsBg.png" mode=""></image>
		</view>
		<view class="security-outer">
			<view class="security">
				您好，为了院区的安全考虑,如果您发现我院存在任何安全隐患，
				非常欢迎您的所见拍下来提交告诉我们,我们会立马排查和处理。谢谢您的配合！
			</view>
		</view>
		<view class="cu-bar bg-white">
			<view class="action">
				图片上传
			</view>
			<view class="action">
				{{imgList.length}}/4
			</view>
		</view>
		
		<view class="cu-form-group cu-form-groupss">
			<view class="grid col-4 grid-square flex-sub">
				<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
				 <image :src="imgList[index]" mode="aspectFill"></image>
					<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
						<text class='cuIcon-close'></text>
					</view>
				</view>
				<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
					<text class='cuIcon-cameraadd'></text>
				</view>
			</view>
		</view>
		<view class="situation">
			<textarea value="" placeholder="请描述下您所遇到的安全隐患情况" />
		</view>
		<view class="submit">
			<button type="primary">提交</button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				imgList: [],
			}
		},
		methods: {
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.img{
		margin:20rpx;
		background-color: #CCCCCC;
		image{
			width:710rpx;
			height:200rpx;
		}
	}
	// F2F2F2
	.security-outer{
		padding: 0 0 20rpx;
		.security{
			padding:20rpx;
			background-color: #FFFFCC;
			line-height:30rpx;
		}
	}
	.situation{
		background-color: #FFFFFF;
		display: flex;
		justify-content: center;
		align-items: center;
		padding:30rpx;
		textarea{
			border-radius: 10rpx;
			padding:10rpx;
			width: 100%;
			border: 1rpx solid #AAAAAA;
		}
	}
	.submit{
		margin:100rpx 30rpx 50rpx;
	}
	
	
	
</style>
